<?php

function get_all_notification($user_id) {
    require(dirname(__FILE__) . '/../config.php');
    require_once(dirname(__FILE__).'/../support/supports_lib.php');
    $con = mysqli_connect($host, $user, $pass, $db);
    mysqli_set_charset($con, "utf8");
    // Check connection
    $all_supports_of_user = get_all_supports_of_user($user_id);
    $notif = array();
    foreach ($all_supports_of_user as $support_of_user) {
        $notif[] = $support_of_user;
    }
    return $notif;
}

function time_ago ($time)
{

    $time = time() - $time; // to get the time since that moment

    $tokens = array (
        31536000 => 'năm',
        2592000 => 'tháng',
        604800 => 'tuần',
        86400 => 'ngày',
        3600 => 'giờ',
        60 => 'phút',
        1 => 'giây'
    );

    foreach ($tokens as $unit => $text) {
        if ($time < $unit) continue;
        $numberOfUnits = floor($time / $unit);
        return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'':'');
    }

}

?>